package com.baizhi.service.impl;

import com.baizhi.dao.CmfzArticleMapper;
import com.baizhi.entity.CmfzArticle;
import com.baizhi.service.CmfzArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CmfzArticleServiceImpl implements CmfzArticleService {
    @Autowired
    private CmfzArticleMapper cmfzArticleMapper;

    @Override
    public Map selectCmfzArticleDatagrid(int page, int rows) {
        Map map=new HashMap();
        int count=cmfzArticleMapper.selectCmfzArticleCount();
        int start=(page-1)*rows;
        List<CmfzArticle> cmfzArticleList=cmfzArticleMapper.selectCmfzArticleDatagrid(start,rows);

        map.put("total",count);
        map.put("rows",cmfzArticleList);
        return map;
    }

    @Override
    public List<CmfzArticle> selectFirstTwoArticle(int userId) {
        return cmfzArticleMapper.selectFirstTwoArticle(userId);
    }

    @Override
    public List<CmfzArticle> getGuruArticle(int userId) {
        return cmfzArticleMapper.getGuruArticle(userId);
    }

    @Override
    public List<CmfzArticle> getNoGuruArticle(int userId) {
        return cmfzArticleMapper.getNoGuruArticle(userId);
    }

    @Override
    public CmfzArticle getOneArticle(int articleId) {
        return cmfzArticleMapper.getOneArticle(articleId);
    }

    @Override
    public void addArticle(CmfzArticle cmfzArticle) {
        cmfzArticleMapper.addArticle(cmfzArticle);
    }

    @Override
    public void deleteSomeArticles(int[] ids) {
        cmfzArticleMapper.deleteSomeArticles(ids);
    }

    @Override
    public void updateArticle(CmfzArticle cmfzArticle) {
        cmfzArticleMapper.updateArticle(cmfzArticle);
    }
}
